use std::ops::{Deref, DerefMut};

pub struct Selector<T> {
    /// 在这个`Selector` 中的元素
   pub elements: Vec<T>,
    /// elements的“当前”(current)元素的指针
    /// `Selector` 的行为类似于指向当前元素的指针
   pub current: usize,
}

impl<T> Deref for Selector<T> {
    type Target = T;

    fn deref(&self) -> &T {
        &self.elements[self.current]
    }
    
}

impl<T> DerefMut for Selector<T> {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.elements[self.current]
    }
}
